package com.baymax.controller;

import com.baymax.common.BaseController;
import com.baymax.common.R;
import com.baymax.entity.SysUser;
import com.baymax.service.SysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 用户 控制层
 *
 * @Author: baymax
 * @CreateTime: 2023/3/30 16:44
 * @Version: 1.0
 */
@RestController
@RequestMapping(value = "/user")
@RequiredArgsConstructor
public class SysUserController extends BaseController {

    private final SysUserService userService;

    @GetMapping
    @PreAuthorize(value = "@el.check('system:user:list')")
    public R list() {
        return success(userService.list());
    }

    @PostMapping
    public R add(@RequestBody SysUser sysUser) {
        return status(userService.add(sysUser));
    }
}
